//
//  MyMessageCenterVC.m
//  Yihubang
//
//  Created by xmy on 16/9/6.
//  Copyright © 2016年 jinghao. All rights reserved.
//

#import "MyMessageCenterVC.h"
#import "MyMessageViewModel.h"
@interface MyMessageCenterVC ()
@property (nonatomic ,strong) MyMessageViewModel * viewModel;
@end

@implementation MyMessageCenterVC
@synthesize viewModel = _viewModel;
@synthesize mTableView = _mTableView;
- (void)viewDidLoad {
    [super viewDidLoad];
    @weakify(self)
    [RACObserve(self, params) subscribeNext:^(id x) {
        @strongify(self)
        self.navigationItem.title =self.params[@"title"];
        if([self.params[@"title"] isEqual:@"我的求助"]){
            self.viewModel.messageType = @"16";
        }else{
            self.viewModel.messageType = @"11";
        }
    }];
    
    self.showLeftMenu =YES;
    [self.viewModel bindTableView:self.mTableView];
    UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithTitle:@"清空" style:UIBarButtonItemStylePlain target:self action:@selector(clearMessage)];
    [self.navigationItem setRightBarButtonItem:backItem];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
-(void)clearMessage {
    [self.viewModel.clearMessageCommend execute:nil];
}
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
//    self.navigationController.navigationBar.hidden = NO;
}

- (MyMessageViewModel *)viewModel{
    if (_viewModel==nil) {
        _viewModel = [[MyMessageViewModel alloc] initWithViewController:self];
    }
    return _viewModel;
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
